/*
package org.example.springboot.common.client;

import com.github.shyiko.mysql.binlog.BinaryLogClient;
import com.github.shyiko.mysql.binlog.event.EventData;
import com.github.shyiko.mysql.binlog.event.TableMapEventData;
import lombok.extern.slf4j.Slf4j;
import org.example.springboot.component.SseEmitterServer;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.io.IOException;

@Component
@Slf4j
public class MysqlBinLogClient implements ApplicationRunner {

    @Resource
    private SseEmitterServer sseEmitterServer;

    @Override
    public void run(ApplicationArguments args) {
        //项目启动完成连接bin-log
        new Thread(this::connectMysqlBinLog).start();

    }

    */
/**
     * 连接mysqlBinLog
     *//*

    public void connectMysqlBinLog() {
        log.info("监控BinLog服务已启动");

        BinaryLogClient client = new BinaryLogClient("8.141.95.31", 33066, "syt", "SYT@62981106&rc6b");
        client.setServerId(100);

        client.registerEventListener(event -> {
            EventData data = event.getData();
            if (data instanceof TableMapEventData) {
                TableMapEventData tableMapEventData = (TableMapEventData) data;

                if (tableMapEventData.getTable().equals("irrigation_unit")) {
                    //可以通过转成TableMapEventData类实例的tableMapEventData来获取当前发生变更的数据库
                    System.out.println("发生变更的数据库：" + tableMapEventData.getDatabase());
                    System.out.print("表ID:");
                    System.out.println(tableMapEventData.getTableId());
                    System.out.print("表名:");
                    System.out.println(tableMapEventData.getTable());
                    //sseEmitterServer.broadcastMessage(new SseDto("Refresh"));
                }
            }
        });

        try {
            client.connect();
        } catch (IOException e) {
            e.printStackTrace();
        }

    }

}
*/
